﻿<Window x:Class="winCapDetails"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:res="clr-namespace:Caps.Console.My.Resources"
    xmlns:my="clr-namespace:Caps.Console"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:t.c="clr-namespace:Tools.WindowsT.WPF.ConvertersT;assembly=Tools.Windows"
    xmlns:convertersT="clr-namespace:Tools.WindowsT.WPF.ConvertersT;assembly=Tools.Windows"
    Title="{x:Static res:Resources.txt_CapDetails}" Height="850" Width="1000"
    DataContext="{Binding SelectedItem, ElementName=lstCaps, Mode=OneWay}"
    Icon="/CapsConsole;component/Resources/Cap.ico"
>
    <Window.Resources>
        <sys:Int32 x:Key="i64">64</sys:Int32>
        <sys:Int32 x:Key="i256">256</sys:Int32>
        <convertersT:NullFalseConverter x:Key="NullFalseConverter"/>
        <my:ObjectImageConverter x:Key="ObjectImageConverter"/>
        <my:PictureTypeConverter x:Key="PictureTypeConverter"/>
        <convertersT:IntColorConverter x:Key="IntColorConverter"/>
        <t.c:CompareConverter x:Key="CompareConverter"/>
        <sys:Int32 x:Key="iOne">1</sys:Int32>
        <convertersT:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter"/>
        <my:CountryCodeFlagConverter x:Key="CountryCodeFlagConverter"/>
        <convertersT:NestedConverter x:Key="Count1HiddenConverter"
            Inner="{StaticResource CompareConverter}"
            Outer="{StaticResource BooleanVisibilityConverter}"
            InnerParam="{StaticResource iOne}"
            OuterParam="!"/>
        <!--<my:StringFormatConverter x:Key="StringFormatConverter"/>-->
        <convertersT:NotVisibilityConverter x:Key="NotVisibilityConverter"/>
        <my:IntColorNameConverter x:Key="IntColorNameConverter"/>
        <convertersT:NotColorConverter x:Key="NotColorConverter"/>
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Open" x:Name="cmdEdit"/>
        <CommandBinding Command="ApplicationCommands.Delete" x:Name="cmdDelete"/>
    </Window.CommandBindings>
    <!--<Window.Style>
        <Style TargetType="Window" BasedOn="{StaticResource {x:Type Window}}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=lstCaps, Path=ItemsSource.Count}" Value="3">
                    <Setter Property="Title" Value="{Binding ElementName=lstCaps, Path=ItemsSource[0].CapName, Converter={StaticResource StringFormatConverter}, ConverterParameter={x:Static res:Resources.txt_CapDetailsFormat}}"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Window.Style>-->
    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> 
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" Name="cdLeft"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <ListBox Grid.Column="0" Grid.Row="0" Name="lstCaps"
                 VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                 Width="auto" SelectedIndex="0"
                 Visibility="{Binding ElementName=lstCaps, Path=ItemsSource.Count, Converter={StaticResource Count1HiddenConverter}}">
            <ListBox.ContextMenu>
                <ContextMenu Name="cmnCaps" >
                    <ContextMenu.Items>
                        <MenuItem Header="{x:Static res:Resources.cmd_Edit}" Command="ApplicationCommands.Open" >
                            <MenuItem.Icon>
                                <Image Source="/CapsConsole;component/Resources/EditInformationHS.png"/>
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem Header="{x:Static res:Resources.cmd_Delete}" Grid.Row="1" Command="ApplicationCommands.Delete" >
                            <MenuItem.Icon>
                                <Image Source="/CapsConsole;component/Resources/DeleteHS.png"/>
                            </MenuItem.Icon>
                        </MenuItem>
                        <MenuItem Header="{x:Static res:Resources.cmd_CapsSearchSimilar}" Click="SeachForSimilar_Click">
                            <MenuItem.Icon>
                                <Image Source="/CapsConsole;component/Resources/FindHS.png"/>
                            </MenuItem.Icon>
                        </MenuItem>
                    </ContextMenu.Items>
                </ContextMenu>
            </ListBox.ContextMenu>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid HorizontalAlignment="Stretch" Width="64" MaxHeight="100" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Image MaxWidth="64" MaxHeight="64"
                            Source="{Binding Path=., Converter={StaticResource ObjectImageConverter}, ConverterParameter={StaticResource i64}, Mode=OneWay}"
                            HorizontalAlignment="Center" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0"/>
                        <TextBlock Text="{Binding CapName, Mode=OneWay}" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="0" Grid.Row="1" TextAlignment="Center" TextWrapping="Wrap" MaxWidth="64" MaxHeight="36"  />
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <Grid Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <Grid.ColumnDefinitions >
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <!--Names-->
            <GroupBox Header="{x:Static res:Resources.txt_Naming}"  Grid.Column="0" Grid.Row="0" >
                <Grid >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <Label Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_Name}"/>
                    <Label Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding CapName, Mode=OneWay}"/>
                    <Label Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_TitleText}"/>
                    <Label Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding MainText, Mode=OneWay}"/>
                    <Label Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_SubtitleText}"/>
                    <Label Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding SubTitle, Mode=OneWay}"/>
                    <Label Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_MainPicture}"/>
                    <Label Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding MainPicture, Mode=OneWay}"/>
                    <Label Grid.Column="0" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_AnotherPictures}"/>
                    <TextBox MinLines="2" Grid.Column="1" Grid.Row="4" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Text="{Binding AnotherPictures, Mode=OneWay}" IsReadOnly="True" TextWrapping="Wrap" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" MaxLines="2" />
                    <Label Grid.Column="0" Grid.Row="5" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_PictureType}"/>
                    <Label Grid.Column="1" Grid.Row="5" VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding PictureType, Converter={StaticResource PictureTypeConverter}, Mode=OneWay}"/>    
                </Grid>
            </GroupBox>
            <!--Colors-->
            <GroupBox Header="{x:Static res:Resources.txt_Colors}" Grid.Column="1" Grid.Row="0">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <Label Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_Background}"/>
                    <Label Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="{Binding BackColor1, Mode=OneWay, Converter={StaticResource IntColorConverter}}" Content="{Binding BackColor1, Mode=OneWay, Converter={StaticResource IntColorNameConverter}}" Foreground="{Binding BackColor1, Mode=OneWay, Converter={StaticResource NotColorConverter}}"/>
                    <Label Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_SecondaryBackground}"/>
                    <Label Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="{Binding BackColor2, Mode=OneWay, Converter={StaticResource IntColorConverter}}" Content="{Binding BackColor2, Mode=OneWay, Converter={StaticResource IntColorNameConverter}}" Foreground="{Binding BackColor2, Mode=OneWay, Converter={StaticResource NotColorConverter}}"/>
                    <Label Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_Foreground}"/>
                    <Label Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="{Binding ForeColor, Mode=OneWay, Converter={StaticResource IntColorConverter}}" Content="{Binding ForeColor, Mode=OneWay, Converter={StaticResource IntColorNameConverter}}" Foreground="{Binding ForeColor, Mode=OneWay, Converter={StaticResource NotColorConverter}}"/>
                    <Label Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_Foreground2}"/>
                    <Label Grid.Column="1" Grid.Row="3" Grid.ColumnSpan="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="{Binding ForeColor2, Mode=OneWay, Converter={StaticResource IntColorConverter}}" Content="{Binding ForeColor2, Mode=OneWay, Converter={StaticResource IntColorNameConverter}}" Foreground="{Binding ForeColor2, Mode=OneWay, Converter={StaticResource NotColorConverter}}"/>
                    <CheckBox Grid.Column="0" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Center" Name="chk3D" Content="{x:Static res:Resources.lbl_3D2}" IsChecked="{Binding Is3D, Mode=OneWay}" IsEnabled="False" />
                    <RadioButton Grid.Column="1" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Center" Width="auto" IsChecked="{Binding Surface, Mode=OneWay, Converter={StaticResource CompareConverter}, ConverterParameter='M'}" Name="optMatting" Content="{x:Static res:Resources.lbl_Matting2}" IsEnabled="False"/>
                    <RadioButton Grid.Column="2" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Center" Width="auto" IsChecked="{Binding Surface, Mode=OneWay, Converter={StaticResource CompareConverter}, ConverterParameter='G'}" Name="optGlossy" Content="{x:Static res:Resources.lbl_Glossy2}" IsEnabled="False"/>
                </Grid>
            </GroupBox>
            <!--Type and size-->
            <GroupBox Header="{x:Static res:Resources.txt_TypeInformation}" Grid.Column="0" Grid.Row="1" Grid.RowSpan="1">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <Label Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_CapType}"/>
                    <Grid Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="auto" Grid.ColumnSpan="2" ToolTip="{Binding CapType.Description, Mode=OneWay}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto" MaxWidth="19" />
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>    
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Image Width="auto" MaxWidth="16" Height="19" VerticalAlignment="Center" Source="{Binding CapType, Converter={StaticResource ObjectImageConverter}, Mode=OneWay}" Margin="0,0,3,0" Grid.Column="0" Grid.Row="0"/>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding CapType.TypeName, Mode=OneWay}" Grid.Column="1" Grid.Row="0"/>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{Binding CapType.CapTypeID, Mode=OneWay}" Grid.Column="2" Grid.Row="0"/>
                    </Grid>
                    <Label Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right"  Width="auto" Content="{x:Static res:Resources.lbl_MainType}"/>
                    <Grid Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="auto" Grid.ColumnSpan="2" ToolTip="{Binding MainType.Description, Mode=OneWay}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto" MaxWidth="19" />
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Image Width="auto" MaxWidth="19" Height="16" VerticalAlignment="Center" Source="{Binding MainType, Converter={StaticResource ObjectImageConverter}, Mode=OneWay}" Margin="0,0,3,0" Grid.Column="0" Grid.Row="0"/>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding MainType.TypeName, Mode=OneWay}" Grid.Column="1" Grid.Row="0"/>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{Binding MainType.MainTypeID, Mode=OneWay}" Grid.Column="2" Grid.Row="0"/>
                    </Grid>
                    <Label Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right"  Width="auto" Content="{x:Static res:Resources.lbl_Shape}"/>
                    <Grid Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="auto" Grid.ColumnSpan="2" ToolTip="{Binding Shape.Description, Mode=OneWay}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto" MaxWidth="19" />
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Image Width="auto" MaxWidth="19" Height="16" VerticalAlignment="Center" Source="{Binding Shape, Converter={StaticResource ObjectImageConverter}, Mode=OneWay}" Margin="0,0,3,0" Grid.Column="0" Grid.Row="0"/>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding Shape.Name, Mode=OneWay}" Grid.Column="1" Grid.Row="0"/>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{Binding Shape.ShapeID, Mode=OneWay}" Grid.Column="2" Grid.Row="0"/>
                    </Grid>
                    <Label Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right"  Width="auto" Content="{Binding Path=Shape.Size1Name, Mode=OneWay}"/>
                    <Label Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding Size, Mode=OneWay}"/>
                    <Label Grid.Column="2" Grid.Row="3" VerticalAlignment="Center" Width="auto" HorizontalAlignment="Left" Content="{x:Static res:Resources.abb_Millimeters}"/>
                    <Label Grid.Column="0" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Right"  Width="auto" Content="{Binding Path=Shape.Size2Name, Mode=OneWay}" Visibility="{Binding Path=Shape.Size2Name, Mode=OneWay, Converter={StaticResource NullFalseConverter}}"/>
                    <Label Grid.Column="1" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding Size2, Mode=OneWay}" Visibility="{Binding Path=Shape.Size2Name, Mode=OneWay, Converter={StaticResource NullFalseConverter}}"/>
                    <Label Grid.Column="2" Grid.Row="4" VerticalAlignment="Center" Width="auto" HorizontalAlignment="Left" Visibility="{Binding Path=Shape.Size2Name, Mode=OneWay, Converter={StaticResource NullFalseConverter}}" Content="{x:Static res:Resources.abb_Millimeters}"/>
                    <Label Grid.Column="0" Grid.Row="5" VerticalAlignment="Center" HorizontalAlignment="Right"  Width="auto" Content="{x:Static res:Resources.lbl_Height}"/>
                    <Label Grid.Column="1" Grid.Row="5" VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding Height, Mode=OneWay}"/>
                    <Label Grid.Column="2" Grid.Row="5" VerticalAlignment="Center" Width="auto" HorizontalAlignment="Left" Content="{x:Static res:Resources.abb_Millimeters}"/>
                    <Label Grid.Column="0" Grid.Row="6" VerticalAlignment="Center" HorizontalAlignment="Right"  Width="auto" Content="{x:Static res:Resources.lbl_Material}"/>
                    <Grid Grid.Column="1" Grid.Row="6" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="auto" Grid.ColumnSpan="2" ToolTip="{Binding Material.Description, Mode=OneWay}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding Material.Name, Mode=OneWay}" Grid.Column="0" Grid.Row="0"/>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{Binding Material.MaterialID, Mode=OneWay}" Grid.Column="1" Grid.Row="0"/>
                    </Grid>
                    <Label Grid.Column="0" Grid.Row="7" VerticalAlignment="Center" HorizontalAlignment="Right"  Width="auto" Content="{x:Static res:Resources.lbl_Target}"/>
                    <Grid Grid.Column="1" Grid.Row="7" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="auto" Grid.ColumnSpan="2" ToolTip="{Binding Target.Description, Mode=OneWay}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding Target.Name, Mode=OneWay}" Grid.Column="0" Grid.Row="0"/>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{Binding Target.MaterialID, Mode=OneWay}" Grid.Column="1" Grid.Row="0"/>
                    </Grid>
                    <Label Grid.Column="0" Grid.Row="8" VerticalAlignment="Top" HorizontalAlignment="Right"  Width="auto" Content="{x:Static res:Resources.lbl_Sign}"/>
                    <ItemsControl Grid.Column="1" Grid.Row="8" VerticalAlignment="Top" HorizontalAlignment="Stretch" Grid.ColumnSpan="2" ItemsSource="{Binding CapSigns, Mode=OneWay}" Grid.IsSharedSizeScope="True">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Vertical" IsItemsHost="True"/>
                            </ItemsPanelTemplate>                                 
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <Grid HorizontalAlignment="Stretch" ToolTip="{Binding Description, Mode=OneWay}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="auto" MaxWidth="35" SharedSizeGroup="c1" />
                                        <ColumnDefinition Width="*" SharedSizeGroup="c2"/>
                                        <ColumnDefinition Width="auto" SharedSizeGroup="c3"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="auto"/>
                                    </Grid.RowDefinitions>
                                    <Image Width="auto" MaxWidth="35" Height="32" VerticalAlignment="Center" Source="{Binding ., Converter={StaticResource ObjectImageConverter}, Mode=OneWay}" Margin="0,0,3,0" Grid.Column="0" Grid.Row="0"/>
                                    <Label VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Content="{Binding Name, Mode=OneWay}" Grid.Column="1" Grid.Row="0"/>
                                    <Label VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{Binding CapSignID, Mode=OneWay}" Grid.Column="2" Grid.Row="0"/>
                                </Grid>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>

                </Grid>
            </GroupBox>
            <!--Buttons-->
            <Grid Grid.Column="0" Grid.Row="2" Width="auto" Height="auto" HorizontalAlignment="Left" VerticalAlignment="Center" Visibility="{Binding ElementName=lstCaps, Path=Visibility, Mode=OneWay, Converter={StaticResource NotVisibilityConverter}}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="18*"/>
                    <ColumnDefinition Width="22.217*" />
                </Grid.ColumnDefinitions>
                <Button Content="{x:Static res:Resources.cmd_Edit}" Command="ApplicationCommands.Open" />
                <Button Content="{x:Static res:Resources.cmd_Delete}" Grid.Row="1" Command="ApplicationCommands.Delete"/>
                <Button Content="{x:Static res:Resources.cmd_CapsSearchSimilar}" Click="SeachForSimilar_Click"/>
            </Grid>
            <!--Texts-->
            <GroupBox Grid.Row="1" Grid.Column="1" Header="{x:Static res:Resources.txt_Texts}" Grid.RowSpan="2" >
                <Grid>
                    <Grid.RowDefinitions >
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions >
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Label Grid.Row="0" Content="{x:Static res:Resources.lbl_TopText}"/>
                    <TextBox Grid.Row="1" MinLines="4" TextWrapping="Wrap" IsReadOnly="True" Text="{Binding TopText, Mode=OneWay}" HorizontalAlignment="Stretch"  ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" MaxLines="4" />
                    <Label Grid.Row="2" Content="{x:Static res:Resources.lbl_SideText}"/>
                    <TextBox Grid.Row="3" MinLines="4" TextWrapping="Wrap" IsReadOnly="True" Text="{Binding SideText, Mode=OneWay}" HorizontalAlignment="Stretch" VerticalScrollBarVisibility="Auto" MaxLines="4" />
                    <Label Grid.Row="4" Content="{x:Static res:Resources.lbl_BottomText}"/>
                    <TextBox Grid.Row="5" MinLines="4" TextWrapping="Wrap" IsReadOnly="True" Text="{Binding BottomText, Mode=OneWay}" HorizontalAlignment="Stretch" VerticalScrollBarVisibility="Auto" MaxLines="4" />
                    <Label Grid.Row="6" Content="{x:Static res:Resources.lbl_Note}"/>
                    <TextBox Grid.Row="7" MinLines="4" TextWrapping="Wrap" IsReadOnly="True" Text="{Binding Note, Mode=OneWay}" HorizontalAlignment="Stretch" VerticalScrollBarVisibility="Auto" MaxLines="4" />
                </Grid>
            </GroupBox>
            <!--Misc-->
            <GroupBox Grid.Column="2" Grid.Row="0" Header="{x:Static res:Resources.txt_Miscellaneous}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions >
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/><RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <Label Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_ID}"/>
                    <Label Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Name="lblID" Content="{Binding CapID, Mode=OneWay}"/>
                    <Label Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_Year}" />
                    <Label Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Left" Content="{Binding Year, Mode=OneWay}"/>
                    <Label Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_Country}"/>
                    <Label Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Content="{Binding CountryCode, Mode=OneWay}"/>
                    <Image Grid.Column="2" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Center" Source="{Binding CountryCode, Mode=OneWay, Converter={StaticResource CountryCodeFlagConverter}}" MaxWidth="32" MaxHeight="16"  />  
                    <Label Grid.Column="0" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_CountryOfOrigin}"/>
                    <Label Grid.Column="1" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Left" Content="{Binding CountryOfOrigin, Mode=OneWay}"/>
                    <Image Grid.Column="2" Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Center" Source="{Binding CountryOfOrigin, Mode=OneWay, Converter={StaticResource CountryCodeFlagConverter}}" MaxWidth="32" MaxHeight="16"/>
                    <Label Grid.Column="0" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_Storage}"/>
                    <Grid Grid.Column="1" Grid.Row="4" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="auto" ToolTip="{Binding Storage.Description, Mode=OneWay}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Grid.Column="0" Grid.Row="0">
                            <Label.Content>
                                <TextBlock>
                                <TextBlock Text="{Binding Storage.StorageNumber, Mode=OneWay}"/>
                                (<TextBlock Text="{Binding Storage.StorageType.Name, Mode=OneWay}"/>)    
                                </TextBlock>
                            </Label.Content>
                        </Label>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{Binding Storage.StorageID, Mode=OneWay}" Grid.Column="1" Grid.Row="0"/>
                    </Grid>
                    <StackPanel Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="3" VerticalAlignment="Center" HorizontalAlignment="Center" Width="auto" Height="auto"  Orientation="Horizontal">
                        <CheckBox Name="chkHasBottom" Content="{x:Static res:Resources.lbl_HasBottom}" Margin="0,0,5,0" IsEnabled="False" IsChecked="{Binding HasBottom, Mode=OneWay}"/>
                        <CheckBox Name="chkHasSide" Content="{x:Static res:Resources.lbl_HasSide}" Margin="5,0,0,0" IsEnabled="False" IsChecked="{Binding HasSide, Mode=OneWay}"/>
                    </StackPanel>
                    <Label Grid.Column="0" Grid.Row="6" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_DateCreated}"/>
                    <Label Grid.Column="1" Grid.Row="6" VerticalAlignment="Center" HorizontalAlignment="Left" Content="{Binding DateCreated, Mode=OneWay}"/>
                    <Label Grid.Column="0" Grid.Row="7" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_State}"/>
                    <Label Grid.Column="1" Grid.Row="7" VerticalAlignment="Center" HorizontalAlignment="Left" Content="{Binding State, Mode=OneWay}"/>                    
                </Grid>
            </GroupBox>
            <!--Product and company-->
            <GroupBox Grid.Column="2" Grid.Row="1" Header="{x:Static res:Resources.txt_CompanyProduct}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <Label Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_Product}"/>
                    <Grid Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="auto" ToolTip="{Binding Product.Description, Mode=OneWay}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Grid.Column="0" Grid.Row="0" Content="{Binding Product.ProductName, Mode=OneWay}"/>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{Binding Product.ProductID, Mode=OneWay}" Grid.Column="1" Grid.Row="0"/>
                    </Grid>
                    <Label Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_ProductType}"/>
                    <Grid Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="auto" ToolTip="{Binding ProductType.Description, Mode=OneWay}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Grid.Column="0" Grid.Row="0" Content="{Binding ProductType.ProductTypeName, Mode=OneWay}"/>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{Binding ProductType.ProductTypeID, Mode=OneWay}" Grid.Column="1" Grid.Row="0"/>
                    </Grid>
                    <Label Grid.Column="0" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{x:Static res:Resources.lbl_Company}"/>
                    <Grid Grid.Column="1" Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Stretch" Width="auto" ToolTip="{Binding Company.Description, Mode=OneWay}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                        </Grid.RowDefinitions>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Left" Width="auto" Grid.Column="0" Grid.Row="0" Content="{Binding Company.CompanyName, Mode=OneWay}"/>
                        <Label VerticalAlignment="Center" HorizontalAlignment="Right" Width="auto" Content="{Binding Company.CompanyID, Mode=OneWay}" Grid.Column="1" Grid.Row="0"/>
                    </Grid>
                    <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal">
                        <CheckBox VerticalAlignment="Center" IsEnabled="False" Content="{x:Static res:Resources.lbl_IsDrink}" IsChecked="{Binding IsDrink, Mode=OneWay}" IsThreeState="True"/>
                        <CheckBox VerticalAlignment="Center" IsEnabled="False" Content="{x:Static res:Resources.lbl_IsAlcoholic}" IsChecked="{Binding IsAlcoholic, Mode=OneWay}" IsThreeState="True"/>
                    </StackPanel> 
                    
                </Grid>

            </GroupBox>
            <!--Categories and keywords-->
            <GroupBox Grid.Column="2" Grid.Row="2" Header="{x:Static res:Resources.txt_CategoriesKeywords}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <GroupBox Header="{x:Static res:Resources.txt_Categories}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="0">
                        <ListBox ItemsSource="{Binding Categories, Mode=OneWay}" Height="auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled"  ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0" BorderThickness="0">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Label ToolTip="{Binding Description, Mode=OneWay}">
                                        <Label.Content>
                                            <TextBlock>
                                                <TextBlock Text="{Binding CategoryName, Mode=OneWay}"/>
                                                (<TextBlock Text="{Binding CategoryID, Mode=OneWay}"/>)
                                            </TextBlock>
                                        </Label.Content>
                                    </Label>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <WrapPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Orientation="Horizontal" IsItemsHost="True" />
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                        </ListBox>
                    </GroupBox>
                    <GroupBox Header="{x:Static res:Resources.txt_Keywords}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="0" Grid.Row="1" >
                        <ListBox ItemsSource="{Binding Keywords, Mode=OneWay}" Height="auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled"  ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0" BorderThickness="0">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Label Content="{Binding Keyword, Mode=OneWay}"/>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <WrapPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Orientation="Horizontal" IsItemsHost="True" />
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                        </ListBox>
                    </GroupBox>
                </Grid>
            </GroupBox>
            <!--Images-->
            <GroupBox Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="3" Header="{x:Static res:Resources.txt_Images}" MinHeight="100">
                <Grid MinHeight="100">
                    <Grid.ColumnDefinitions >
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <ListBox  Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="lvwImages" MinHeight="100" ItemsSource="{Binding ImagesOrdered, Mode=OneWay}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Hidden">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Width="64" Height="100" MouseDown="Image_MouseDown">
                                    <Grid.ToolTip>
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="256"/>
                                            </Grid.ColumnDefinitions>
                                            <Grid.RowDefinitions>
                                                <RowDefinition MaxHeight="256" Height="auto" />
                                                <RowDefinition Height="auto"/> 
                                            </Grid.RowDefinitions>
                                            <Image MaxWidth="256" MaxHeight="256" HorizontalAlignment="Center"  
                                                Source="{Binding ., Mode=OneWay, Converter={StaticResource ObjectImageConverter}, ConverterParameter={StaticResource i256}}"
                                                Width="auto" Height="auto"/>
                                            <TextBlock Text="{Binding RelativePath, Mode=OneWay}" Grid.Column="0" Grid.Row="1"/>
                                        </Grid>
                                    </Grid.ToolTip>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="64"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="64"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Image Source="{Binding ., Mode=OneWay, Converter={StaticResource ObjectImageConverter}, ConverterParameter={StaticResource i64}}" MaxWidth="64" MaxHeight="64" Width="auto" Height="auto"/>
                                    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" Grid.Row="1" Grid.Column="0" Text="{Binding RelativePath, Mode=OneWay}" Width="auto" Height="auto" TextWrapping="Wrap" TextAlignment="Center"/>
                                    <CheckBox IsEnabled="False"
                                              IsChecked="{Binding IsMain, Mode=Oneway}"
                                              Visibility="{Binding IsMain, Mode=OneWay, Converter={StaticResource BooleanVisibilityConverter}}"
                                              Grid.Column="0" Grid.Row="0"
                                              HorizontalAlignment="Right" VerticalAlignment="Top"
                                              ToolTip="{x:Static res:Resources.tot_ThisIsMainImage}"/>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel IsItemsHost="True" Orientation="Horizontal" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ItemHeight="100" MinHeight="64" ItemWidth="64"/>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                </Grid>
            </GroupBox>
     </Grid>
    </Grid>
</Window>
